/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.colegiatura.bc;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.colegiatura.be.TipoImagen;

/**
 *
 * @author ADMINISTRADOR
 */
@Stateless
public class TipoImagenFacade implements TipoImagenFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(TipoImagen tipoImagen) {
        em.persist(tipoImagen);
    }

    public void edit(TipoImagen tipoImagen) {
        em.merge(tipoImagen);
    }

    public void remove(TipoImagen tipoImagen) {
        em.remove(em.merge(tipoImagen));
    }

    public TipoImagen find(Object id) {
        return em.find(TipoImagen.class, id);
    }

    public List<TipoImagen> findAll() {
        return em.createQuery("select object(o) from TipoImagen as o where o.timCodigo in(1,2,3,4,5,6)").getResultList();
    }

    public List<TipoImagen> listaParaTemporal() {
        String sql = "select object(o) from TipoImagen as o where o.timCodigo in (1,4,5,8,11)";
        return em.createQuery(sql).getResultList();
    }

    public List<TipoImagen> listaParaExterno() {
        String sql = "select object(o) from TipoImagen as o where o.timCodigo in (1,2,3,11)";
        return em.createQuery(sql).getResultList();
    }

    public List<TipoImagen> listarTodo() {
        return em.createQuery("select object(o) from TipoImagen as o where o.timCodigo in(1,2,3,4,5,6,9,10)").getResultList();
    }

}
